<!--巡河页面-->
<style lang="less" scoped>
.patrol {
  margin: 15px;
  .smallForm {
    display: inline-block;
  }
  .smallArr {
    width: 15%;
    display: inline-block;
  }
  .bigModal {
    width: 400px;
    height: 300px;
  }
  .bigModal1 {
    width: 500px;
    height: 500px;
  }
  .img {
    display: flex;
    width: 100%;
  }
  .bigimg {
    width: 100%;
    height: 600px;
  }
  .reportModal {
    .ivu-modal-body {
      float: left;
    }
    .imgBox {
      display: flex;
    }
  }
}
</style>

<template>
    <div class="patrol">
        <Card :bordered="false">
            <p slot="title" class="white">巡河记录</p>
            <div>
                <Form :model="searchItem" class="smallForm">
                    <Input v-model="searchItem.river_name" style="width:200px;margin-right: 15px;" :maxlength="30" placeholder="请输入河流名称"></Input>
                    <Input v-model="searchItem.chref_name" style="width:200px;margin-right: 15px;" :maxlength="30" placeholder="请输入河长"></Input>
                    <DatePicker @on-change="change" format="yyyy-MM-dd" type="daterange" placeholder="请选择巡河日期" style="width: 250px;margin-right: 30px;"></DatePicker>
                    <dep-select @getData="getDepData" style="width:200px;margin-right: 15px;"></dep-select>
                    <area-select @getData="getAreaData" style="width:200px;"></area-select>
                </Form>
                <Button type="info" style="margin-left:15px" @click="getTableData('1')">搜索</Button>
                <Button type="success" style="margin-left:15px" @click="Daochu">巡河记录导出</Button>
            </div>
        </Card>
        <Table :data="patrolData" :columns="patrolColumns" stripe></Table>
        <Page
            class="pull-right"
            :total="Page.total"
            :current="Page.current"
            :page-size="Page.pageSize"
            size="small"
            show-total
            @on-change="changePage"
        ></Page>
        <Modal v-model="mapModal" width="1000">
            <p slot="header" style="color:#f60;text-align:center">
                查看巡查事件
                <div style="float: left">
                    <img src="/static/img/gis1.png" height="30" width="30" alt="">
                    <span>景观</span>
                    <img src="/static/img/weizhi.png" height="30" width="30" alt="">
                    <span>举报</span>
                </div>
            </p>
            <div id="map" style="width: 100%;height: 600px;" ref="map">

            </div>
        </Modal>
        <Modal class="spe-modal" v-model="modal1" width="1000" style="text-align:center;position: relative">
            <Icon type="chevron-left" style="font-size: 50px;position:absolute;top: 35%;left:5%;color: #CCC;cursor: pointer" @click.native="changeImge('left')"></Icon>
            <img :src="imgSrc" alt="" style="max-width: 100%;max-height: 750px;">
            <Icon type="chevron-right" style="font-size: 50px;position:absolute;top: 35%;right:5%;color: #CCC;cursor: pointer" @click.native="changeImge('right')"></Icon>
        </Modal>
        <Modal v-model="modal2" class="reportModal" title="查看举报事件" width="800">
            <Form :model="formItem" :label-width="80">
                <i-col span="12">
                    <Form-item label="河流名称" prop="river_name">
                        <Input v-model="formItem.river_name" readonly></Input>
                    </Form-item>
                    <Form-item label="所属区" prop="area">
                        <Input v-model="formItem.area" readonly></Input>
                    </Form-item>
                    <Form-item label="所属河长办" prop="river_name">
                        <Input v-model="formItem.dep_name" readonly></Input>
                    </Form-item>
                    <Form-item label="事件状态" prop="solve_is">
                        <Input v-model="formItem.solve_is" readonly></Input>
                    </Form-item>
                </i-col>
                <i-col span="12">
                    <Form-item label="巡河人" prop="contacts">
                        <Input v-model="formItem.contacts" readonly></Input>
                    </Form-item>
                    <Form-item label="所属镇" prop="town">
                        <Input v-model="formItem.town" readonly></Input>
                    </Form-item>
                    <Form-item label="事件时间" prop="report_time">
                        <Input v-model="formItem.report_time" readonly></Input>
                    </Form-item>
                    <Form-item label="事件描述" prop="overview">
                        <Input v-model="formItem.overview" readonly></Input>
                    </Form-item>
                </i-col>
                <i-col span="24">
                    <div class="imgBox">
                        <img class="smallImg1" :src="imgSrc1">
                        <img class="smallImg1" v-if="imgSrc2_true" :src="imgSrc2">
                        <img class="smallImg1" v-if="imgSrc3_true" :src="imgSrc3">
                    </div>
                </i-col>
            </Form>
        </Modal>
        <Modal v-model="printModal" @on-ok="print" title="巡河记录表打印预览" width="1200" style="text-align: center">
            <iframe id="patrolTable" v-if="printPdf !== ''" style="width:100%;height:700px" :src="printPdf"></iframe>
            <img src="../a-picture/img/aPictureNoCount.png" v-else height="255" width="340" alt="">
            <div slot="footer">
                <Button  type="primary" @click="print">打印</Button>
                <Button  @click="printModal = false">取消</Button>
            </div>
        </Modal>
        <lc :row="saveRow" ref="lc"></lc>
        <more ref="more"></more>
        <pictures ref="pictures"></pictures>
    </div>
</template>

<script>
import lc from 'public/lc'
import more from 'public/more'
import { ajaxPost } from 'global/axios'
import storage from 'good-storage'
import picture from 'public/picture'
import areaSelect from 'public/areaSelect'
import depSelect from 'public/depSelect'
import tableDropdown from 'public/tableHeaderDropdown'
import { domain, domain2 } from 'global/setting'
export default {
  components: {
    'more': more,
    'lc': lc,
    'pictures': picture,
    'area-select': areaSelect,
    'dep-select': depSelect
  },
  data () {
    return {
      patrolUrlList: '/emergency/patrol/viewwithother',
      patrolFindList: '/emergency/patrol/find',
      urlTreeList: '/sys/department/getTree',
      urlRiverList: '/bsi/riverchief/list',
      urlUserList: '/sys/userinfo/list',
      urlManual: '/emergency/patrol/manualnew',
      urlDao: '/emergency/patrol/makexml',
      patrolData: [],
      printPdf: '',
      manualModal: false,
      printModal: false,
      isWork: false, // 是否河长界面
      imgList: [],
      manual: {
        start_time: '',
        end_time: ''
      },
      saveRow: {},
      userArr: [],
      riverArr: [],
      reportColumn: [
        {
          type: 'index',
          width: 60,
          align: 'center'
        },
        {
          title: '时间',
          key: 'report_time'
        },
        {
          title: '地址',
          key: 'address'
        },
        {
          title: '所属区',
          render: (h, params) => {
            return params.row.location.area
          }
        },
        {
          title: '所属镇',
          render: (h, params) => {
            return params.row.location.town
          }
        },
        {
          title: '状态',
          width: 150,
          render: (h, params) => {
            if (params.row.solve_is == '已处理') {
              return params.row.pro_name
            } else {
              return h(
                'div',
                {
                  style: {
                    cursor: 'pointer'
                  },
                  on: {
                    click: () => {
                      this.saveRow = params.row
                      setTimeout(() => { that.$refs.lc.showModal(params.row) }, 100)
                    }
                  }
                },
                params.row.pro_name
              )
            }
          }
        },
        {
          title: '操作',
          render: (h, params) => {
            return h('div', [
              h(
                'Button',
                {
                  props: {
                    type: 'primary',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      this.showImg(params.row.photos, 1)
                    }
                  }
                },
                '查看举报图片'
              ),
              h(
                'Button',
                {
                  props: {
                    type: 'info',
                    size: 'small'
                  },
                  style: {
                    marginRight: '5px'
                  },
                  on: {
                    click: () => {
                      this.$refs.more.print(params.row, 4)
                    }
                  }
                },
                '详情'
              )
            ])
          }
        }
      ],
      patrolColumns: [
        {
          type: 'expand',
          width: 50,
          render: (h, params) => {
            return h('Table', {
              props: {
                data: params.row.report,
                columns: this.reportColumn
              },
              ref: 'myRef'
            })
          }
        },
        {
          type: 'index',
          width: 60,
          align: 'center'
        },
        {
          title: '河长',
          minWidth: 80,
          key: 'personel_name'
        },
        {
          title: '河流名称',
          minWidth: 100,
          key: 'river_name'
        },
        {
          title: '所属区',
          minWidth: 90,
          render: (h, params) => {
            return h('div', {}, params.row.location.area)
          }
        },
        {
          title: '所属镇',
          minWidth: 110,
          render: (h, params) => {
            return h('div', {}, params.row.location.town)
          }
        },
        {
          title: '等级',
          minWidth: 90,
          renderHeader: (h, params) => {
            return h(tableDropdown, {
              props: {
                placement: 'bottom-start',
                showArrow: true,
                content: '等级',
                data: [{ value: 'all', name: '全部' }, { value: '3', name: '市级' }, { value: '2', name: '区级' }, { value: '1', name: '镇级' }, { value: '0', name: '村级' }]
              },
              on: {
                'on-choosed': (data) => {
                  if (data !== 'all') {
                    this.searchItem.user_type = data
                    this.getTableData()
                  } else {
                    this.searchItem.user_type = ''
                    this.getTableData()
                  }
                }
              }
            })
          },
          render: (h, params) => {
            if (params.row.user_type === '3') {
              return h('div', {}, '市级')
            } else if (params.row.user_type === '2') {
              return h('div', {}, '区级')
            } else if (params.row.user_type === '1') {
              return h('div', {}, '镇级')
            } else if (params.row.user_type === '0') {
              return h('div', {}, '村级')
            }
          }
        },
        {
          title: '本次巡河景观图',
          minWidth: 135,
          align: 'center',
          key: 'personel_name',
          render: (h, params) => {
            return h(
              'div',
              {
                style: {
                  cursor: 'pointer'
                },
                on: {
                  click: () => {
                    let photo = []
                    if (params.row.scenery.length > 0) {
                      params.row.scenery.map(item => {
                        photo.push(item.photo)
                      })
                    }
                    this.$refs.pictures.showImg(photo)
                  }
                }
              },
              params.row.scenery.length
            )
          }
        },
        {
          title: '本次巡河事件',
          minWidth: 120,
          align: 'center',
          render: (h, params) => {
            return h('div', {}, params.row.report.length)
          }
        },
        {
          title: '巡查日期',
          minWidth: 100,
          render: (h, params) => {
            return h('div', {}, params.row.end_time.substr(0, 10))
          }
        },
        {
          title: '巡查时间',
          minWidth: 100,
          key: 'runtime'
        },
        {
          title: '是否偏移了河流轨迹',
          minWidth: 120,
          render: (h, params) => {
            if (params.row.is_near == 0) {
              return h('div', {}, '否')
            } else {
              return h('div', {}, '是')
            }
          }
        },
        {
          title: '工作简报',
          minWidth: 100,
          render: (h, params) => {
            let path = ''
            let filename = ''
            if (params.row.prove_file !== undefined && params.row.prove_file.path !== '') {
              path = params.row.prove_file.path
              filename = params.row.prove_file.filename
              return h('div', [
                h('a', {
                  on: {
                    click: () => {
                      diyDownload(path, filename)
                    }
                  },
                  domProps: {
                    title: filename
                  }
                },
                  filename
                )
              ])
            } else {
              return h('div', '暂无数据')
            }
          }
        },
        {
          title: '创建人',
          key: 'initer_name',
          minWidth: 90
        },
        {
          title: '巡河类型',
          key: 'patrol_type',
          minWidth: 100
        },
        {
          title: '操作',
          key: 'action',
          width: 360,
          render: (h, param) => {
            if (
              param.row.end_time !== undefined &&
              param.row.end_time !== undefined
            ) {
              if (param.row.pdf_place === undefined) {
                return h('div', [
                  h(
                    'Button',
                    {
                      props: {
                        type: 'primary',
                        size: 'small'
                      },
                      style: {
                        marginRight: '5px'
                      },
                      on: {
                        click: () => {
                          this.showMap(param.row)
                        }
                      }
                    },
                    '查看巡河轨迹'
                  ),
                  h(
                    'Button',
                    {
                      props: {
                        type: 'success',
                        size: 'small',
                        disabled: true
                      },
                      style: {
                        marginRight: '5px'
                      },
                      on: {
                        click: () => {
                          this.printModal = true
                          if (param.row.pdf_place !== undefined) {
                            this.printPdf = `${domain}/emergency/patrol/patrolcreate?patrol_no=${param.row.patrol_no}`
                          }
                        }
                      }
                    },
                    '打印巡河记录表'
                  )
                ])
              } else {
                return h('div', [
                  h(
                    'Button',
                    {
                      props: {
                        type: 'primary',
                        size: 'small'
                      },
                      style: {
                        marginRight: '5px'
                      },
                      on: {
                        click: () => {
                          this.showMap(param.row)
                        }
                      }
                    },
                    '查看巡河轨迹'
                  ),
                  h(
                    'Button',
                    {
                      props: {
                        type: 'success',
                        size: 'small'
                      },
                      style: {
                        marginRight: '5px'
                      },
                      on: {
                        click: () => {
                          this.printModal = true
                          if (param.row.pdf_place !== undefined) {
                            this.printPdf = `${domain
                              }/emergency/patrol/patrolcreate?patrol_no=${param.row.patrol_no
                              }`
                          }
                        }
                      }
                    },
                    '打印巡河记录表'
                  )
                ])
              }
            } else {
              return '巡查尚未结束'
            }
          }
        }
      ],
      Page: {
        current: 1,
        pageSize: 14,
        total: 0
      },
      mapModal: false,
      modal1: false,
      modal2: false,
      imgSrc: '',
      actionPage: '1',
      formItem: {
        river_name: '',
        contacts: '',
        area: '',
        town: '',
        dep_name: '',
        report_time: '',
        solve_is: '',
        overview: ''
      },
      searchItem: {
        river_name: '',
        chref_name: '',
        report_time: [],
        deps: '',
        areas: ''
      },
      imgSrc1: '',
      imgSrc2: '',
      imgSrc3: '',
      imgSrc2_true: false,
      imgSrc3_true: false,
      areaArr1: [],
      route: []
    }
  },
  methods: {
    print () {
      var iframe = document.getElementById('patrolTable')
      iframe.contentWindow.focus()
      iframe.contentWindow.print()
      this.printModal = false
    },
    getDep () {
      var params = {
        data: {},
        url: this.urlTreeList,
        token: storage.session.get('token'),
        success: res => {
          this.areaArr1 = res.data.result
        }
      }
      ajaxPost(params)
    },
    getTableData (page = 1) {
      let myBasis = this.isWork ? 5 : 2;
      let params = {
        data: {
          page: page,
          pageSize: this.Page.pageSize,
          searchValue: {
            patrol_is: '已结束'
          },
          basis: myBasis,
          order: { end_time: -1 }
        },
        url: this.patrolUrlList,
        token: storage.session.get('token'),
        success: res => {
          this.$Loading.finish()
          this.patrolData = res.data.result.result
          this.Page.total = res.data.result.totalSize
        }
      }
      if (this.searchItem.river_name !== '') {
        params.data.searchValue.river_name =
          this.searchItem.river_name + '|#|like'
      }
      if (this.searchItem.chref_name !== '') {
        params.data.searchValue.personel_name =
          this.searchItem.chref_name + '|#|like'
      }
      if (this.searchItem.report_time.length != 0) {
        params.data.searchValue.end_time =
          this.searchItem.report_time[0] +
          ' 00:00:00|#|' +
          this.searchItem.report_time[1] +
          ' 23:59:59'
      }
      if (this.searchItem.deps !== '') {
        params.data.searchValue['location.dep_name'] = this.searchItem.deps
      }
      if (this.searchItem.areas !== '') {
        this.areaList.map(item => {
          if (this.searchItem.areas === item.name) {
            if (item.level == '2') {
              params.data.searchValue['location.area'] = item.name
            } else if (item.level == '3') {
              params.data.searchValue['location.town'] = item.name
            }
          }
        })
      }
      ajaxPost(params)
    },
    change (data) {
      if (data[0] === '') {
        this.searchItem.report_time = []
        return
      }
      this.searchItem.report_time = data
    },
    showMap (row) {
      this.mapModal = true
      var center = new qq.maps.LatLng(row.route[0].lat, row.route[0].lng)
      var map = new qq.maps.Map(document.getElementById('map'), {
        center: center,
        zoom: 16
      })
      var path1 = []
      for (var i = 0; i < row.route.length; i++) {
        path1.push(new qq.maps.LatLng(row.route[i].lat, row.route[i].lng))
      }
      var polyline = new qq.maps.Polyline({
        path: path1,
        strokeColor: '#FF0000',
        strokeWeight: 2,
        editable: false,
        map: map
      })
      var params = {}
      params.data = {}
      params.data.searchValue = {
        patrol_no: row.patrol_no
      }
      params.token = storage.session.get('token')
      params.url = this.patrolFindList
      params.success = function (res) {
        console.log(res.data.result)
        if (res.data.result.reports.length > 0) {
          var html = ''
          res.data.result.reports.map(function (item, index) {
            var marker = new qq.maps.Marker({
              position: new qq.maps.LatLng(item.lat, item.lng),
              map: map
            })
            var anchor = new qq.maps.Point(0, 39),
              size = new qq.maps.Size(42, 68),
              origin = new qq.maps.Point(0, 0),
              markerIcon = new qq.maps.MarkerImage(
                'static/img/weizhi.png',
                size,
                origin,
                anchor
              )
            marker.setIcon(markerIcon)
            var info = new qq.maps.InfoWindow({
              map: map
            })
            for (let i = 0; i < item.photos.length; i++) {
              html +=
                '<img style="max-width:200px;max-height:200px;margin-right:5px;" src="' +
                domain2 +
                item.photos[i] +
                '">'
            }
            qq.maps.event.addListener(marker, 'click', function () {
              info.open()
              info.setContent(
                '<div class="bigModal"><p>' +
                item.report_time +
                '</p><p>' +
                item.overview +
                '</p><div class="img">' +
                html +
                '</div></div>'
              )
              info.setPosition(new qq.maps.LatLng(item.lat, item.lng))
            })
          })
        }
        if (res.data.result.scenerys.length > 0) {
          res.data.result.scenerys.map(item => {
            var html = ''
            var marker = new qq.maps.Marker({
              position: new qq.maps.LatLng(item.lat, item.lng),
              map: map
            })
            var anchor = new qq.maps.Point(0, 39),
              size = new qq.maps.Size(42, 68),
              origin = new qq.maps.Point(0, 0),
              markerIcon = new qq.maps.MarkerImage(
                '/static/img/gis1.png',
                size,
                origin,
                anchor
              )
            marker.setIcon(markerIcon)
            var info = new qq.maps.InfoWindow({
              map: map
            })
            html +=
              '<img style="max-width:500px;max-height:300px;margin-right:5px;" src="' +
              domain2 +
              item.photo +
              '">'
            qq.maps.event.addListener(marker, 'click', function () {
              info.open()
              info.setContent(
                '<div class="bigModal1"><p>' +
                item.date_time +
                '</p><div class="img">' +
                html +
                '</div></div>'
              )
              info.setPosition(new qq.maps.LatLng(item.lat, item.lng))
            })
          })
        }
      }
      ajaxPost(params)
    },
    displayFeatureInfo (evt) {
      var that = this
      layers.Map.forEachFeatureAtPixel(evt.pixel, function (feature, layer) {
        console.log(feature)
        if (feature.get('content').photo) {
          var src = feature.get('content').photo
          that.showImg(src)
        } else {
          var row = feature.get('content')
          that.showReport(row)
        }
      })
    },
    createFeatures (LNT, LAT, data = [], img, scale = 2) {
      let features = []
      for (let i = 0; i < data.length; i++) {
        if (+data[i][LNT] && +data[i][LAT]) {
          let feature = new ol.Feature(
            new ol.geom.Point([data[i][LNT], data[i][LAT]])
          )
          feature.set(
            'style',
            new ol.style.Style({
              image: new ol.style.Icon({
                src: img,
                scale: scale
              })
            })
          )
          feature.set('content', data[i])
          features.push(feature)
        }
      }
      return features
    },
    createFeaturesLayer (name, features, zIndex = 1) {
      return new ol.layer.Vector({
        style: function (feature) {
          return feature.get('style')
        },
        source: new ol.source.Vector({
          features: features
        }),
        name: name,
        zIndex: zIndex
      })
    },
    createGeo (type, coordinates, item) {
      return {
        geometry: {
          type: type,
          coordinates: coordinates
        },
        properties: {
          ...item
        },
        type: 'Feature'
      }
    },
    createMap (el, layers) {
      return new ol.Map({
        target: el,
        layers: layers,
        view: new ol.View({
          center: [113.12484741210938, 23.009912294150357],
          zoom: 10,
          maxZoom: 19,
          minZoom: 0,
          projection: 'EPSG:4326'
          // extent: [109.6820068359375, 20.264282226562504, 116.8670654296875, 25.3729248046875]
        }),
        controls: ol.control.defaults({
          attribution: false
        })
      })
    },
    changePage: function (page) {
      this.getTableData(page)
      this.actionPage = page
    },
    showImg (row, type) {
      this.imgList = []
      if (type == 0) {
        if (row.scenery.length > 0) {
          row.scenery.map(item => {
            this.imgList.push(item.photo)
          })
          this.modal1 = true
        }
      } else if (type == 1) {
        row.map(item => {
          this.imgList.push(item)
        })
        this.modal1 = true
      }
      setTimeout(() => {
        this.imgSrc = domain2 + this.imgList[0]
      }, 50)
    },
    showReport (row) {
      this.modal2 = true
      this.formItem.river_name = row.river_name
      this.formItem.contacts = row.contacts
      this.formItem.area = row.location.area
      this.formItem.town = row.location.town
      this.formItem.dep_name = row.location.dep_name
      this.formItem.report_time = row.report_time
      this.formItem.solve_is = row.solve_is
      this.formItem.overview = row.overview
      if (row.photos.length > 2) {
        this.imgSrc2_true = true
        this.imgSrc3_true = true
      } else if (row.photos.length == 2) {
        this.imgSrc2_true = true
        this.imgSrc3_true = false
      } else {
        this.imgSrc2_true = false
        this.imgSrc3_true = false
      }

      this.imgSrc1 = domain2 + row.photos[0]
      this.imgSrc2 = domain2 + row.photos[1]
      this.imgSrc3 = domain2 + row.photos[2]
    },
    showMap2 () {
      var that = this
      var myMap = document.getElementById('patrolMap')
      myMap.innerHTML = ''
      var center = new qq.maps.LatLng(23.02, 113.12)
      let maps = new qq.maps.Map(document.getElementById('patrolMap'), {
        center: center,
        zoom: 11,
        disableDoubleClickZoom: false
      })
      let path1 = []
      let listener = qq.maps.event.addListener(maps, 'click', event => {
        var cirle = new qq.maps.Circle({
          center: new qq.maps.LatLng(
            event.latLng.getLat(),
            event.latLng.getLng()
          ),
          radius: 4,
          fillColor: '#ff0000',
          map: maps
        })
        path1.unshift(
          new qq.maps.LatLng(event.latLng.getLat(), event.latLng.getLng())
        )
        var polyline = new qq.maps.Polyline({
          path: path1,
          strokeColor: '#ff0000',
          strokeWeight: 3,
          editable: false,
          map: maps
        })
        this.route.push({
          lat: event.latLng.getLat(),
          lng: event.latLng.getLng()
        })
      })
    },
    change2 (data) {
      this.manual.start_time = data + ':00'
    },
    change3 (data) {
      this.manual.end_time = data + ':00'
    },
    newpartol () {
      let river_no
      this.riverArr.map(item => {
        if (this.manual.river_name === item.river_name) {
          river_no = item.river_no
        }
      })
      let params = {
        data: {
          river_name: this.manual.river_name,
          username: this.manual.username,
          start_time: this.manual.start_time,
          end_time: this.manual.end_time,
          river_no: river_no,
          route: this.route
        },
        url: this.urlManual,
        token: storage.session.get('token'),
        success: res => {
          if (res.data.code == '0000') {
            this.$Loading.finish()
            this.$Message.success({
              content: '录入成功'
            })
            this.getTableData(this.actionPage)
          } else {
            this.$Message.warning({
              content: res.data.message
            })
          }
        }
      }
      ajaxPost(params)
    },
    Daochu () {
      let params = {
        data: {
          searchValue: {},
          order: { end_time: -1 }
        },
        token: storage.session.get('token'),
        url: this.urlDao,
        success: res => {
          let url2 = res.data.result
          fetch(url2).then(res =>
            res.blob().then(blob => {
              var a = document.createElement('a')
              var url = window.URL.createObjectURL(blob)
              var filename = '巡查记录表'
              a.href = url
              a.download = filename
              a.click()
              window.URL.revokeObjectURL(url)
            })
          )
        }
      }
      if (this.isWork) {
        params.data.basis = 5;
      }
      if (this.searchItem.river_name !== '') {
        params.data.searchValue.river_name =
          this.searchItem.river_name + '|#|like'
      }
      if (this.searchItem.chref_name !== '') {
        params.data.searchValue.personel_name =
          this.searchItem.chref_name + '|#|like'
      } else if (this.searchItem.report_time.length != 0) {
        params.data.searchValue.end_time =
          this.searchItem.report_time[0] +
          ' 00:00:00|#|' +
          this.searchItem.report_time[1] +
          ' 23:59:59'
      } else if (this.searchItem.deps.length !== '') {
        params.data.searchValue['location.dep_name'] = this.searchItem.deps
      }
      ajaxPost(params)
    },
    getAreaData (data) {
      this.searchItem.areas = data
    },
    getDepData (data) {
      if (data === undefined) {
        this.searchItem.deps = ''
      } else {
        this.searchItem.deps = data
      }
    }
  },
  mounted: function () {
    this.isWork = storage.session.get('isWork');
    this.getTableData()
    this.getDep()
  }
}
</script>
